package com.example.moblie2030606150cjk0330;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {



    private EditText edtTxtMainAccount;
    private EditText edtTxtMainPsw;
    private Button btnMainLogin;
    private Button btnMainReset;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        btnMainLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String account=edtTxtMainAccount.getText().toString();
                String psw=edtTxtMainPsw.getText().toString();
                if (account.length() == 0) {
                    Log.i("登录", "请输入用户名");

                }else if (psw.length()==0){
                    Log.i("登录", "请输入密码");
                }
                else{
                    if (account.equals("admin") & psw.equals("123456")) {
                        Log.i("登录", "登录成功");
                    } else {
                        Log.i("登录", "登录失败");
                    }
                    edtTxtMainPsw.setText(null);
                    edtTxtMainAccount.setText(null);
                }
            }
        });


        btnMainReset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                edtTxtMainPsw.setText(null);
                edtTxtMainAccount.setText(null);
            }
        });



    }

    private void initView() {

        edtTxtMainAccount = (EditText) findViewById(R.id.edtTxt_main_account);
        edtTxtMainPsw = (EditText) findViewById(R.id.edtTxt_main_psw);
        btnMainLogin = (Button) findViewById(R.id.btn_main_login);
        btnMainReset = (Button) findViewById(R.id.btn_main_reset);
    }


    @Override
    public void onClick(View v) {

    }
}